<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变量运算</title>
    <script>
        function f1(){
            // 使用基本运算的时候,用法与java基本一致
            // +、-、*、/、%、+=、-=...
            let num1 = 3;
            let num2 = 2;
            console.log(num1+"+"+num2+"="+(num1+num2));
            console.log(num1+"-"+num2+"="+(num1-num2));
            console.log(num1+"*"+num2+"="+(num1*num2));
            console.log(num1+"/"+num2+"="+(num1/num2));
            console.log(num1+"%"+num2+"="+(num1%num2));
            console.log(num1+=1); // num1 = num1+1
            console.log(num1-=1);
            console.log(num2++)
            console.log(num2)
            console.log(num1 > num2 ? "大于" : "小于等于");
            console.log(num1>num2 && num1<num2);
            console.log(num1>num2 || num1<num2);
        }
        function f2(){
            let num = 2;
            let s = "2";
            // 在js中,使用==判断时只考虑值的大小,不考虑类型
            console.log(num == s);
            // 但是,在某些特殊情况下,可能需要考虑类型
            // 可以使用js提供的恒等于进行判断,===
            console.log(num === s);
        }
        function f3(){
            // 模方运算是ES6语法
            // x**y表示x的y次方
            console.log(3**2);
            console.log(2**3);
            console.log(200**3);
        }
    </script>
</head>
<body>
<button onclick="f1()">基本运算</button>
<button onclick="f2()">恒等于</button>
<button onclick="f3()">模方运算</button>
</body>
</html>